<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html;" charset="<?php echo CHARSET;?>">
<title>本地生活</title>
<link href="/Public/admin/css/skin_0.css" rel="stylesheet" type="text/css" id="cssfile"/>
<script type="text/javascript" src="/Public/static/jquery.js"></script>
<script type="text/javascript" src="/Public/static/jquery.validation.min.js"></script>
<script type="text/javascript" src="/Public/admin/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Public/admin/js/admincp.js"></script>
<script type="text/javascript" src="/Public/admin/js/jquery.tooltip.js"></script>
<script language="javascript">
var SiteUrl = '<?php echo (C("SiteUrl")); ?>';
var AdminUrl = SiteUrl+'/<?php echo (MODULE_NAME); ?>';
</script>
</head><body>
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>广告管理</h3>
      <ul class="tab-base">
        <li><a href="<?php echo U('Billboards/position');?>"><span>管理</span></a></li>
        <li><a href="JavaScript:void(0);" class="current"><span>编辑</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="link_form" enctype="multipart/form-data" method="post">
   <input name="ap_id" type="hidden" value="<?php echo ($vo['ap_id']); ?>"/>
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="ap_name">名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" name="ap_name" id="ap_name"  value="<?php echo ($vo['ap_name']); ?>" class="txt">
            </td>
          <td class="vatop tips"></td>
        </tr>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="ap_code">广告位置:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
          <select name='ap_code'>
              <option value="">请选择</option>
              <?php if(is_array($apcode)): $i = 0; $__LIST__ = $apcode;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo['ap_code']); ?>" <?php if($search == $vo['ap_code']): ?>selected<?php endif; ?>><?php echo ($vo['name']); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
          </select>
          <!-- <select name="ap_code" id="ap_code">
          <option value="">请选择...</option>
          <option value="banner" <?php if($vo['ap_code'] == 'banner_bangdan_video'): ?>selected="selected"<?php endif; ?>>首页视频幻灯片</option>
              <option value="banner" <?php if($vo['ap_code'] == 'banner_bangdan_voice'): ?>selected="selected"<?php endif; ?>>首页音频幻灯片</option>
              <option value="banner" <?php if($vo['ap_code'] == 'banner_bangdan_photo'): ?>selected="selected"<?php endif; ?>>首页照片幻灯片</option>
          <option value="img_nav" <?php if($vo['ap_code'] == 'img_nav'): ?>selected="selected"<?php endif; ?>>首页图片导航栏</option>
          <option value="static_img" <?php if($vo['ap_code'] == 'static_img'): ?>selected="selected"<?php endif; ?>>首页静态广告</option>
          <option value="foot-img" <?php if($vo['ap_code'] == 'foot-img'): ?>selected="selected"<?php endif; ?>>底部许可证</option>
          </select> -->
          </td>
          <td class="vatop tips"></td>
        </tr>           
<!--         <tr>
          <td colspan="2" class="required"><label for="sg_description">广告位描述:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
          	<textarea id="sg_description" name="ap_intro" class="tarea" ><?php echo ($vo['ap_intro']); ?></textarea>
          </td>
          <td class="vatop tips"></td>
        </tr>     --> 
        <tr class="noborder">
          <td colspan="2" class="required"><label for="ap_link">链接地址:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" name="ap_link" value="<?php echo ($vo['ap_link']); ?>" id="ap_link" class="txt">
            </td>
          <td class="vatop tips">以http://开头</td>
        </tr>
<!--        <tr class="noborder">
          <td colspan="2" class="required"><label for="ap_price">价格:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" name="ap_price" value="<?php echo ($vo['ap_price']); ?>" id="ap_price" class="txt">
            </td>
          <td class="vatop tips"></td>
        </tr>     -->   
<!--        <tr>
          <td colspan="2" class="required">
          	<label>广告类型:</label>
          </td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
          	<select name="ap_class" id="ap_class">
            <?php if($vo['ap_class'] == 2): ?><option value="2" selected="selected">图片</option>
            <?php else: ?>  
              <option value="1" selected="selected">文字</option><?php endif; ?>  
            </select>
		  </td>
          <td class="vatop tips">选择此广告位广告的形式</td>
        </tr>-->
<!--        <tr>
          <td colspan="2" class="required">是否使用:</td>
        </tr>
        <tr class="noborder">
			<td class="vatop rowform">
				<ul>
	              <li>
	                <input name="is_use" type="radio" value="1" <?php if($vo['is_use'] == 1): ?>checked="checked"<?php endif; ?>>
	                <label>是</label>
	              </li>
	              <li>
	                <input type="radio" name="is_use" value="0" <?php if($vo['is_use'] == 0): ?>checked="checked"<?php endif; ?>>
	                <label>否</label>
	              </li>
	            </ul>
            </td>
          <td class="vatop tips"></td>
        </tr>-->
      </tbody>

      <tbody>
        <tr>
          <td colspan="2" class="required"><label class="validation" for="change_default_pic">图片</label></td>
        </tr>
          <td class="vatop rowform">
          	<span class="type-file-show">
          		<img class="show_image" src="/Public/admin/images/preview.png">
            	<div class="type-file-preview">
            		<img style="width: 300px;height: 150px;" src="<?php echo $vo2['ap_pic'];?>">
            	</div>
            </span>
            <span class="type-file-box">
            <input type='text' name='txt_default_pic' id='txt_default_pic' class='type-file-text' />
            <input type='button' name='but_default_pic' id='but_default_pic' value='' class='type-file-button' />
            <input name="default_pic" type="file" class="type-file-file" id="default_pic" size="30" hidefocus="true" nc_type="change_default_pic">
            </span>
          </td>
          <td class="vatop tips"></td>
      </tbody>
<!--      <tbody id="ap_width_media">
        <tr>
          <td colspan="2" class="required"><label class="validation" for="ap_width_media_input">宽度:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="<?php echo ($vo['ap_width']); ?>" name="ap_width"  class="txt" id="ap_width_media_input"></td>
          <td class="vatop tips">像素</td>
        </tr>
	  </tbody>
      <tbody id="ap_height">
        <tr>
          <td colspan="2" class="required"><label class="validation" for="ap_height_input">高度:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="<?php echo ($vo['ap_height']); ?>" name="ap_height" class="txt" id="ap_height_input"></td>
          <td class="vatop tips">像素</td>
        </tr>
      </tbody>
   
      <tbody id="default_word">
        <tr>
          <td colspan="2" class="required"><label for="default_word" class="validation">文字:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" id="default_word" value="<?php echo ($vo['default_content']); ?>" name="default_content" class="txt">
            </td>
          <td class="vatop tips">当没有广告可供展示时使用的默认文字</td>
        </tr>
      </tbody>-->
      <tbody id="ap_sort_media">
        <tr>
          <td colspan="2" class="required"><label class="validation" for="ap_sort_media_input">宽度:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="<?php echo ($vo['ap_sort']); ?>" name="ap_sort"  class="txt" id="ap_sort_media_input"></td>
          <td class="vatop tips"></td>
        </tr>
	  </tbody>
    <tbody id="default_word">
    <tr>
      <td colspan="2" class="required"><label>简介:</label></td>
    </tr>
    <tr class="noborder">
      <td class="vatop rowform">
      <textarea name="ap_intro" rows="6" class="tarea" id="ap_intro"><?php echo ($vo['ap_intro']); ?></textarea>
      </td>
      <td class="vatop tips"></td>
    </tr>  
      <tfoot>
        <tr class="tfoot">
          <td colspan="15" ><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>保存</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script>
//按钮先执行验证再提交表单
$(function(){$("#submitBtn").click(function(){
    if($("#link_form").valid()){
     $("#link_form").submit();
	}
	});
});
//
$(document).ready(function(){
	
	$('#link_form').validate({
        errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        success: function(label){
            label.addClass('valid');
        },
        rules : {
        	ap_name : {
                required : true
            },
			ap_code : {
				 required : true	
			},			
            ap_link:{
				url : true
           	}
/*			ap_width:{
				required :function(){return $("#ap_class").val()!=1;},
				digits	 :true,
				min:1
			},
			ap_height:{
				required :function(){return $("#ap_class").val()!=1;},
				digits	 :true,
				min:1
			},
			default_content  :{
				required :function(){return $("#ap_class").val()==1;}
			}*/
        },
        messages : {
        	ap_name : {
                required : '请输入标题'
            },
			ap_code : {
				 required : '请输入调用代码'	
			},				
            ap_link : {
				url : '链接地址格式错误'
            }
/*	
            ap_width	:{
            	required : '请输入宽度',
            	digits	:'格式错误',
            	min	:'1px以上'
            },
            ap_height	:{
            	required   : '请输入高度',
            	digits	:'格式错误',
            	min	:'1px以上'
            },            
            default_content	:{
            	required   : '请输入文字信息'
            }*/
        }
    });
});
</script>
<script type="text/javascript">
// 模拟网站LOGO上传input type='file'样式
$(function(){
	$("#default_pic").change(function(){
		$("#txt_default_pic").val($(this).val());
	});
// 上传图片类型
$('input[class="type-file-file"]').change(function(){
	var filepatd=$(this).val();	
	var extStart=filepatd.lastIndexOf(".");
	var ext=filepatd.substring(extStart,filepatd.lengtd).toUpperCase();		
		if(ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
			alert("图片格式错误");
				$(this).attr('value','');
			return false;
		}
	});
});
</script>
</body></html>